﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZSens
{
    public abstract class Widget
    {
        public abstract WidgetType GetWidgetType();
        public string GetDisplayString()
        {
            return "not impl yet";
        }
        public Widget()
        {
            BindedAction = new List<Action>();
        }
        public virtual void Serialize(StringBuilder sb)
        {
            sb.Append((byte)GetWidgetType());
        }
        public List<Action> BindedAction { get; set; }
    }
    public interface BoolProvider
    {
        bool GetState();
    }
    public interface FloatProvider
    {
        float GetState();
    }
    
    public enum WidgetType
    {
        Button, ThrottleBar,
        OrientationX, OrientationY,
        Hat
    }
    public class Button
        : Widget,BoolProvider
    {
        public float ltx, lty, rbx, rby;

        public Button(float ltx, float lty, float rbx, float rby)
        {
            this.ltx = ltx;
            this.lty = lty;
            this.rbx = rby;
            this.rby = rby;
        }

        public bool GetState()
        {
            return false;
        }

        public override void Serialize(StringBuilder sb)
        {
            sb.Append((byte)GetWidgetType());
            sb.Append(ltx);
            sb.Append(lty);
            sb.Append(rbx);
            sb.Append(rby);
        }

        public override WidgetType GetWidgetType()
        {
            return WidgetType.Button;
        }
    }
    public class ThrottleBar
        : Widget, FloatProvider
    {
        public float GetState()
        {
            return 0;
        }
        public override WidgetType GetWidgetType()
        {
            throw new NotImplementedException();
        }
    }
    public abstract class Orientation
        : Widget, FloatProvider
    {
        public float GetState()
        {
            return 0;
        }
    }
    public sealed class OrientationX
        : Orientation
    {
        
        public override WidgetType GetWidgetType()
        {
            return WidgetType.OrientationX;
        }
    }
    public sealed class OrientationY
        : Orientation
    {
        public override WidgetType GetWidgetType()
        {
            return WidgetType.OrientationY;
        }
    }
    public sealed class Hat
        : Widget, FloatProvider
    {
        public float GetState()
        {
            return 0;
        }
        public override WidgetType GetWidgetType()
        {
            throw new NotImplementedException();
        }
    }
}
